Python:如何解决因pip安装请求而失败的错误 您所在的位置:网站首页 python cv2下载失败 Python:如何解决因pip安装请求而失败的错误

Python:如何解决因pip安装请求而失败的错误

2023-03-12 08:47| 来源: 网络整理| 查看: 265

"错误状态"

python中,使用pip安装请求模块以导入"请求"时,可能会出现以下错误。 python的版本是2.7。

12345$ pip install requests Collecting requests   Could not fetch URL https://pypi.python.org/simple/requests/: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590) - skipping   Could not find a version that satisfies the requirement requests (from versions: ) No matching distribution found for requests

显然,我在ssl证书周围出现错误。

"解决方案"

解决方案很简单,可以通过更新pip进行修复。

123456789101112131415$ curl https://bootstrap.pypa.io/get-pip.py | python   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current                                  Dload  Upload   Total   Spent    Left  Speed 100 1604k  100 1604k    0     0  1375k      0  0:00:01  0:00:01 --:--:-- 1375k Collecting pip   Downloading https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl (1.3MB)     100% |████████████████████████████████| 1.3MB 2.7MB/s Collecting wheel   Downloading https://files.pythonhosted.org/packages/81/30/e935244ca6165187ae8be876b6316ae201b71485538ffac1d718843025a9/wheel-0.31.1-py2.py3-none-any.whl (41kB)     100% |████████████████████████████████| 51kB 3.0MB/s Installing collected packages: pip, wheel   Found existing installation: pip 8.1.1     Uninstalling pip-8.1.1:       Successfully uninstalled pip-8.1.1 Successfully installed pip-18.0 wheel-0.31.1

再次运行" pip安装请求"

123456789101112131415161718sh-3.2# pip install requests Collecting requests   Downloading https://files.pythonhosted.org/packages/65/47/7e02164a2a3db50ed6d8a6ab1d6d60b69c4c3fdf57a284257925dfc12bda/requests-2.19.1-py2.py3-none-any.whl (91kB)     100% |████████████████████████████████| 92kB 2.1MB/s Collecting idna=2.5 (from requests)   Downloading https://files.pythonhosted.org/packages/4b/2a/0276479a4b3caeb8a8c1af2f8e4355746a97fab05a372e4a2c6a6b876165/idna-2.7-py2.py3-none-any.whl (58kB)     100% |████████████████████████████████| 61kB 3.1MB/s Collecting urllib3=1.21.1 (from requests)   Downloading https://files.pythonhosted.org/packages/bd/c9/6fdd990019071a4a32a5e7cb78a1d92c53851ef4f56f62a3486e6a7d8ffb/urllib3-1.23-py2.py3-none-any.whl (133kB)     100% |████████████████████████████████| 143kB 3.8MB/s Collecting chardet=3.0.2 (from requests)   Downloading https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133kB)     100% |████████████████████████████████| 143kB 2.4MB/s Collecting certifi>=2017.4.17 (from requests)   Downloading https://files.pythonhosted.org/packages/7c/e6/92ad559b7192d846975fc916b65f667c7b8c3a32bea7372340bfe9a15fa5/certifi-2018.4.16-py2.py3-none-any.whl (150kB)     100% |████████████████████████████████| 153kB 3.5MB/s Installing collected packages: idna, urllib3, chardet, certifi, requests Successfully installed certifi-2018.4.16 chardet-3.0.4 idna-2.7 requests-2.19.1 urllib3-1.23

成功。

参考:确认SSL证书时遇到问题--OSX·问题号5236·pypa / pip



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

      专题文章
        CopyRight 2018-2019 实验室设备网 版权所有